package com.fitso.model.service.food;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.NotImplementedException;
import org.springframework.stereotype.Service;

import com.fitso.model.bean.nutrition.Food;
import com.fitso.model.bean.nutrition.FoodDescription;
import com.fitso.model.dao.FoodDao;

/**
 * Simple call through to the underlying dao
 * 
 * @author timothystorm
 */
@Service("SimpleFoodService")
public class SimpleFoodService implements FoodService {
	@Resource(name = "HibernateFoodDao")
	private FoodDao _foodDao;

	public void save(Food food) {
		if (food != null) {
			_foodDao.createOrUpdate(food);
		}
	}

	public void save(List<Food> foods) {
		if (foods != null && !foods.isEmpty()) {
			_foodDao.createOrUpdate(foods);
		}
	}

	public Food fetchById(Long id) {
		return _foodDao.readById(id);
	}

	public List<Food> fetchById(List<Long> ids) {
		return _foodDao.readById(ids);
	}

	public void delete(Food food) {
		if (food != null) {
			_foodDao.delete(food);
		}
	}

	public void delete(List<Food> foods) {
		if (foods != null && !foods.isEmpty()) {
			_foodDao.delete(foods);
		}
	}

	public List<Food> fetchLikeDescription(FoodDescription description) {
		throw new NotImplementedException("not implemented yet");
	}
}
